package alvarodelrosal.chat.client.chataction.infraestructuraremota;

import alvarodelrosal.chat.client.gui.MainWindow;
import alvarodelrosal.chat.client.modelo.Conversation;
import java.util.HashSet;
import java.util.Set;

public class OnlineConversations {

    private static Set<Conversation> conversations = new HashSet();
    
    public static void addConversation(Conversation conversation) {
        MainWindow.addConversation(conversation);
        conversations.add(conversation);
    }
    
    public static Set<Conversation> getAllConversations() {
        return conversations;
    }
    
    public static void removeAllConversations() {
        MainWindow.removeAllConversations();
        conversations.clear();
    }
    
    public static Conversation getConversation(int conversationId) {
        for(Conversation conversation : conversations) {
            if (conversation.getId() == conversationId) {
                return conversation;
            }
        }
        throw new IllegalArgumentException("Conversation doesn't exists");
    }
    
    
    
}
